<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
	<form class="form-horizontal business-form" id="credit-info">
		<div class="current-state-bno">
			<div class="submit-buttonleft">
				<button class="btn-danger-my btn  btn-success" type="button" onclick="createdcRecord();">新增</button>
				<button class="btn  btn-danger" type="button" onclick="deletedcRecord();">删除</button>
			</div>
		</div>

		<div class="ibox-content" style="clear: none;">
			<div class="jqGrid_wrapper">
				<table id="table_list_2"></table>
				<div id="pager_list_2"></div>
			</div>
		</div>
	</form>
	
	<%@include file="/jsp/comm_js_include.jsp"%>
	<script type="text/javascript">
	var winWidthdc = $("#table_list_2").parent('div.ibox-content').width();
    var winHeightdc = document.body.offsetHeight - 450;
	var getCollectionRecord=function(){
		    var win = winWidth / 7 - 20;
	 	    $.jgrid.defaults.styleUI = 'Bootstrap';
	 	    var data={};
	 	    data.busiId=$.getUrlData("busiId");
	 	    data.orderSql="created desc";
			$("#table_list_2").jqGrid({
				show:false,
				url:'${basePath}/DhOverdueCollectionPhoneController/list',
		       	datatype : "json",
		       	postData:data,
		       	colNames : ['主键','是否已还','催收时间', '允诺时间','逾期原因', '催收记录','催收人'],
			    colModel : [ 
					 {name: 'replaceId',hidden:true},  
		             {name: 'statusRepayment',index: 'statusRepayment',width: 100,align: "center",sorttype: "float",formatter:function(cellvalue, options, rowObject){
		            	 if(cellvalue == "01"){  
		                     return "已还";   
		                 }else{  
		                     return "未还";   
		                 }  
		             }},
		             {name: 'timeCollection',index: 'timeCollection',width: 150,align: "center",sorttype: "float",formatter:function(a,b,c){
                       	 return formateStringDate(a);
                     }},
		             {name: 'timeRepaymentPromise',index: 'timeRepaymentPromise',width: 150,align: "center",sorttype: "float",formatter:function(a,b,c){
                       	 return formateStringDate(a);
                     }},
		             {name: 'reasonOverdueDisplay',index: 'reasonOverdue',width: 300,align: "center",sorttype: "float"},
		             {name: 'remarks',index: 'remarks',width: 500,align: "center",sorttype: "float"},
		             {name: 'creatorName',index: 'creatorName',width: 130,align: "center",sorttype: "float"},
		             ],
		           mtype : "post",
		           height: winHeightdc,
		           width:winWidthdc,  
		           autowidth: false,
		           shrinkToFit: false,
		           rowNum: 15,
		           rowList: [15, 30, 45],
		           viewrecords: true,
		           pager: "#pager_list_2",
		           hidegrid: false,
		           multiselect : true,		//实现单选    multiboxonly:true   beforeSelectRow: true,
		           multiboxonly:false,  
		           altRows:true,
		           altclass:'someClass',
		           beforeSelectRow: false,
		           ondblClickRow:function(rowId,v,e){
	            	  var rowData = $("#table_list_2").jqGrid("getRowData", rowId);
	            	  var remarks = rowData.remarks;
	            	  var content = '<div class="remarks-padding">'+remarks+'</div>'
	            	  layer.open({
	     	 			  title:'催收记录',
	     				  type: 1,
	     				  area: ['400px', '300px'], //宽高
	     				  content: content
	     	    	  });
	                },
		           jsonReader: {
		                root: "result.rows",
		                page: "result.page",
		                total: "result.total",
		                records: "result.records",
		                repeatitems: false,
		                id: "id"
		            },
		            loadComplete:function(datas){
		          	  if (datas.flag == "100100") {
		                   // layer.msg("查询成功!", {icon: 6, time: 1000});
		                    return;
		                }
		          	  if(datas.flag == '100802') {
		  				  top.location.href = thisLoginUrl;
		  				  return;
		  			  }

		          	  layer.msg(datas.message, {icon: 2});
		            }
		      });
        }
	
		var deletedcRecord=function(){
	 		var delId = "";
	 		var data={};
	 		var ids = $("#table_list_2").jqGrid("getGridParam", "selarrrow"); 
	 		for(var i=0;i<ids.length;i++){
	 		  var rowData = $("#table_list_2").jqGrid('getRowData',ids[i]);
	 		      delId += rowData.replaceId + ",";
	 		}
	 		data.id= delId;
	 		if(data.id == ""){
	 			layer.msg('请选择一条数据删除！', {icon: 5});
	 			return;
	 		}
	 		
	 		layer.confirm('您确认要删除吗？', {
	 		     btn: ['确定','取消'] //按钮
	 		},function(){
	 			layer.closeAll();
 	 		$.dpAjax({
        		show:false,
	    		url:'${basePath}/DhOverdueCollectionPhoneController/remove',
	    		data:data,
    			success: function(datas){
	    			  layer.msg('执行成功！', {icon: 6});
	    			  refreshb();
					  return;
                 }
	    	});
	 		})	
	 	}
	</script>